*** Settings ***
Library           FN

*** Test Cases ***
3.1 用户当年存在一个无需结算的账单，不存在的serviceType查询年账单，返回为空
    Init Step
    ${interface}    Set Variable    cn.com.servyou.business.obc.facade.BillQueryFacade
    ${method}    Set Variable    queryByYear
    ${customerId}    Get UUID
    ${serviceType}    Set Variable    PTS-NOEXSITED
    ${year}    Set Variable    2020
    ${month}    Set Variable    1
    ${new_bill_sql}    Create Oec Bill    ${OBC_BILL_NONEED}    ${customerId}    ${year}    ${month}
    Redis Step
    Connect To Redis    ${OBC_REDIS_URL}    ${OBC_REDIS_ALIAS}
    ${redis_key}    Get Year Bill Key    ${customerId}    ${PTS_INFO['serviceType']}    ${year}
    Delete Key From Redis    ${OBC_REDIS_ALIAS}    ${redis_key}
    Mysql Step
    Connect To Database    pymysql    ${OBC_DB_URL}    ${OBC_DB_ALIAS}
    Execute Sql String    ${OBC_DB_ALIAS}    DELETE from obc_fee_bill where customer_id = '${customer_id}'    ${DB_OP_TYPE_DELETE}
    Execute Sql String    ${OBC_DB_ALIAS}    ${new_bill_sql}    ${DB_OP_TYPE_DELETE}
    Doing Step
    ${post_data}    Create Dictionary
    Set To Dictionary    ${post_data}    customerId    ${customerId}
    Set To Dictionary    ${post_data}    serviceType    ${serviceType}
    Set To Dictionary    ${post_data}    year    ${year}
    ${resp}    Dubbo Invoke    ${OBC_ZK_ADDR}    ${interface}    ${method}    ${post_data}    ${DUBBO_PAMAR_STRING}
    Check Step
    Redis Key Should Be Exist    ${OBC_REDIS_ALIAS}    ${redis_key}
    Length Should Be    ${resp['list']}    0
    Validate Schema    ${resp}
    Close Step
    Close Database    ${OBC_DB_ALIAS}
    Close Redis    ${OBC_REDIS_ALIAS}

3.2 用户当年存在一个无需结算的账单，不存在的customerId查询年账单，返回为空
    Init Step
    ${interface}    Set Variable    cn.com.servyou.business.obc.facade.BillQueryFacade
    ${method}    Set Variable    queryByYear
    ${customerIdPre}    Get UUID
    ${customerId}    Set Variable    ${customerIdPre}-new
    ${serviceType}    Set Variable    ${PTS_INFO['serviceTypeName']}
    ${year}    Set Variable    2020
    ${month}    Set Variable    1
    Redis Step
    Connect To Redis    ${OBC_REDIS_URL}    ${OBC_REDIS_ALIAS}
    ${redis_key}    Get Year Bill Key    ${customerId}    ${PTS_INFO['serviceType']}    ${year}
    Delete Key From Redis    ${OBC_REDIS_ALIAS}    ${redis_key}
    Mysql Step
    Connect To Database    pymysql    ${OBC_DB_URL}    ${OBC_DB_ALIAS}
    Execute Sql String    ${OBC_DB_ALIAS}    DELETE from obc_fee_bill where customer_id = '${customer_id}'    ${DB_OP_TYPE_DELETE}
    Doing Step
    ${post_data}    Create Dictionary
    Set To Dictionary    ${post_data}    customerId    ${customerId}
    Set To Dictionary    ${post_data}    serviceType    ${serviceType}
    Set To Dictionary    ${post_data}    year    ${year}
    ${resp}    Dubbo Invoke    ${OBC_ZK_ADDR}    ${interface}    ${method}    ${post_data}    ${DUBBO_PAMAR_STRING}
    Check Step
    Redis Key Should Not Be Exist    ${OBC_REDIS_ALIAS}    ${redis_key}
    Length Should Be    ${resp['list']}    1
    Validate Schema    ${resp}
    Close Step
    Close Database    ${OBC_DB_ALIAS}
    Close Redis    ${OBC_REDIS_ALIAS}

3.3 用户当年存在一个无需结算的账单，不存在的year查询年账单，返回为空
    Init Step
    ${interface}    Set Variable    cn.com.servyou.business.obc.facade.BillQueryFacade
    ${method}    Set Variable    queryByYear
    ${customerId}    Get UUID
    ${serviceType}    Set Variable    ${PTS_INFO['serviceTypeName']}
    ${year}    Set Variable    2020
    ${month}    Set Variable    9
    ${new_bill_sql}    Create Oec Bill    ${OBC_BILL_NONEED}    ${customerId}    ${year}    ${month}
    Redis Step
    Connect To Redis    ${OBC_REDIS_URL}    ${OBC_REDIS_ALIAS}
    ${redis_key}    Get Year Bill Key    ${customerId}    ${PTS_INFO['serviceType']}    ${year}
    Delete Key From Redis    ${OBC_REDIS_ALIAS}    ${redis_key}
    Mysql Step
    Connect To Database    pymysql    ${OBC_DB_URL}    ${OBC_DB_ALIAS}
    Execute Sql String    ${OBC_DB_ALIAS}    DELETE from obc_fee_bill where customer_id = '${customer_id}'    ${DB_OP_TYPE_DELETE}
    Execute Sql String    ${OBC_DB_ALIAS}    ${new_bill_sql}    ${DB_OP_TYPE_DELETE}
    Doing Step
    ${post_data}    Create Dictionary
    Set To Dictionary    ${post_data}    customerId    ${customerId}
    Set To Dictionary    ${post_data}    serviceType    ${serviceType}
    Set To Dictionary    ${post_data}    year    ${year}0
    ${resp}    Dubbo Invoke    ${OBC_ZK_ADDR}    ${interface}    ${method}    ${post_data}    ${DUBBO_PAMAR_STRING}
    Check Step
    Redis Key Should Be Exist    ${OBC_REDIS_ALIAS}    ${redis_key}
    Length Should Be    ${resp['list']}    0
    Validate Schema    ${resp}
    Close Step
    Close Database    ${OBC_DB_ALIAS}
    Close Redis    ${OBC_REDIS_ALIAS}
